<style scoped>
.el-card{border-radius: 10px;width: 100%;margin-bottom: 10px;}
.count_outer{flex-wrap: wrap;width: 100%;}
.count_outer li{border: 01px solid var(--sm_main);border-radius: 10px;margin: 10px;width: auto;min-width: 160px;padding: 10px;text-align: center;}
.count_outer li>b{display: block;font-size: 2em;}
</style>
<template>
  <list_url ref="list_url" :config="config" @search="get_count_all">
    <template #head_extend>
      <ul class="flex count_outer" v-if="in_right_admin('Count/user_kickback_withdraw_all')">
        <template v-for="row in count_list">
          <el-tooltip v-if="row.show" :content="row.tips" placement="top">
            <li @click="row.onclick" :style="{cursor:typeof row.onclick=='function' ? 'pointer' : 'default' }" >
              <p>{{row.content}}</p>
              <b class="text-ellipsis">{{row.value}}</b>
            </li>
          </el-tooltip>
        </template>
      </ul>
    </template>
  </list_url>
</template>
<script>
import {_href} from "@/js/s94_tool.js";
import {in_right_admin} from "@/js/tool.js";
import s94Mjs from "s94-js";
import {use_status_alias_map} from "@/store/config_map.js";
import {ajax} from "@/js/api_tool.js";

export default {
  props: ['__iframe'],
  data(){
    let app = this, btns = {}, is_del = this.$get('is_del');

    if(in_right_admin('Count/user_kickback_withdraw_export')) btns['导出'] = function(){
      let param = s94Mjs.param_encode(app.$refs['list_url'].$refs['forms'].form_data());
      window.open(_href("/admin/count/user_kickback_withdraw_export?"+param), '_blank')
    }
    let forms_config = {
      keyword: {label:'昵称/电话',name:'where[nickname|phone][like]',type:'text_one',value:''},
      can_withdraw: {label:'可提现',name:'where[can_withdraw][between]',type:'text_between',value:''},
      time_between: {label:'时间范围',name:'time_between',type:'date_between',value:'',config:'Y-M-D'},
    };
    let list_cols = {
      id: {name:'id', label:'ID', width:'65px', fixed:'left'},
      head_img:{name:'head_img', label:'头像', width:'45px', type:'file_img'},
      phone:{name:'phone', label:'电话号码', width:'120px'},
      nickname:{name:'nickname', label:'昵称', min_width:'120px'},
      kickback_money_0:{name:'kickback_money_0', label:'待入帐', width:'130px', order:true},
      kickback_money_1:{name:'kickback_money_1', label:'已入账', width:'130px', order:true},
      not_withdraw:{name:'not_withdraw', label:'未提现', width:'130px', order:true},
      can_withdraw:{name:'can_withdraw', label:'可提现', width:'130px', order:true},
      withdraw_money_0:{name:'withdraw_money_0', label:'待结算(提现中)', width:'130px', order:true},
      withdraw_money_1:{name:'withdraw_money_1', label:'已提现', width:'130px', order:true},
    };
    // list_cols['action'] = {name:'action', label:'操作', width:'140px', type:'action', fixed:'right'};

    return {
      config: {
        api: '/admin/count/user_kickback_withdraw',
        title: "佣金统计"+(is_del?'(已删除)':''),
        btns: btns,
        forms_config: forms_config,
        list_cols: list_cols,
        resdata: function(list){
          return list;
        },
        limit: 20,
        p: this.$get('p', 1),
      },
      count_list: {
        kickback_money_0:{content:'待入帐', tips:'所有`待入账`的总金额', value:0},
        kickback_money_1:{content:'已入账', tips:'所有`已入账`的总金额', value:0},
        not_withdraw:{content:'未提现', tips:'所有`未提现`的总金额，注：未提现=已入账-待结算-已提现', value:0},
        can_withdraw:{content:'可提现', tips:'所有`可提现`的总金额，注：可提现和未提现的区别在于，可提现需要佣金入账一定时间后(系统配置)，才符合可提现标准', value:0},
        withdraw_money_0:{content:'待结算', tips:'所有`待结算`(提现中)的总金额', value:0},
        withdraw_money_1:{content:'已提现', tips:'所有`已提现`的总金额', value:0},
      },
    }
  },
  methods: {
    in_right_admin,
    get_count_all(fd){
      if (!in_right_admin('Count/user_kickback_withdraw_all')) return;
      ajax({url:"/admin/count/user_kickback_withdraw_all", data:fd, method:"post"}, (res)=>{
        Object.keys(this.count_list).forEach(k=>{
          let row = this.count_list[k];
          row.show = (k in res.data);
          if (row.show){
            row.value = res.data[k];
          }
        })
      })
    },
  },
  mounted() {
    let app = this;
    if (!this.__iframe) window['app'] = this;


  }
}
</script>
